/*
  File: Date.h
  RCD A.2
  File taken from Section 9.8 of "Programming Principles and Practice Using C++" by Bjarne Stroustrup, unless noted otherwise
*/
#ifndef DATE_H_	//include guards
#define DATE_H_	//include guards
#include<iostream>
using namespace std;

class Date {
 public:
  enum Month {jan=1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec};
  class Invalid{};	//exception class
  
  Date(int y, Month m, int d);	//check for valid date and initialize
  Date();	//default constructor
  
  //nonmodifying operations
  int day() const {return d;}
  Month month() const {return m;}
  int year() const {return y;}
  
  //modifying operations
  void add_day(int n);
  void add_month(int n);
  void add_year(int n);
  void sort_year();
  
 private:
  int y;
  Month m;
  int d;

  //  void inc_Month();	//RCD A.2  increment month by one
};

bool is_date(int y, Date::Month m, int d);	//true for valid date
  
bool leapyear(int y);	//true if y is a leap year
  
bool operator==(const Date& a, const Date& b);
bool operator!=(const Date& a, const Date& b);

std::ostream& operator<<(ostream& os, const Date& d);

std::istream& operator>>(istream& is, Date& dd);

#endif //DATE_H_
